<?php
//爬虫
//获得栏目id
header("Content-type:text/html;charset=utf-8");
$category = $_GET['cid'];
if($category){
	$con = mysql_connect('localhost','root','root') or die('请检查数据库连接'.mysql_error());
	mysql_query("SET NAMES utf8");
	$db = mysql_select_db("get_content",$con);
	if(!$db){
		die("数据库不存在".mysql_error());
	}else {
		//获得提取规则数组
		$sql = "SELECT * FROM `spiders` WHERE `category` = '".$category."'";
		$result = mysql_query($sql);
		$row = mysql_fetch_row($result);
		//var_dump($row);
	}
}else{
	exit("出错了:(");
}

//获取页面的地址
$list_url = $row[5];
$list_content = file_get_contents($list_url);

$list_match = $row[2];//获取列表正则规则
$content_match = $row[3];//获得文章内容正则规则
preg_match_all($list_match,$list_content,$list_data);
$i = 0;

//获取得到了一个链接列表
foreach($list_data[1] as $detail_url){
	$detail_content = file_get_contents("http://auto.sina.com.cn".$detail_url);
	//获取标题
	preg_match();
}
mysql_free_result($result);
mysql_close($db);





?>